package it.asvp.asvp_portal.data.entity.library;


import it.asvp.asvp_portal.data.entity.domain.File;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@SuppressWarnings("serial")
@Entity
@Table(name = "library_picture", catalog = "asvp_db", uniqueConstraints = @UniqueConstraint(columnNames = {
		"id_library", "id_picture" }))
public class LibraryPicture implements java.io.Serializable {

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_picture", nullable = false)
	@Cascade({CascadeType.ALL})
	private File file;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_library", nullable = false)
	private Library library;

	public LibraryPicture() {
	}

	public LibraryPicture(File file, Library library) {
		this.file = file;
		this.library = library;
	}

	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}


	public File getFile() {
		return this.file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	
	public Library getLibrary() {
		return this.library;
	}

	public void setLibrary(Library library) {
		this.library = library;
	}

}
